<template>
  <view class="web-container">
    <web-view :src="url" @message="handleMessage"></web-view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        url: '',
        title: ''
      }
    },
  onLoad(options) {
    console.log('-----------3-web----------', options)
      if (options.url && options.url.indexOf('https') !== -1) {
        this.url = decodeURIComponent(options.url) 
      }else {
        this.url = 'https://www.baidu.com'
      }
      if (options.title) {
        this.title = decodeURIComponent(options.title)
        uni.setNavigationBarTitle({
          title: this.title
        })
      }
    },
    methods: {
      handleMessage(e) {
        console.log('收到webview消息:', e.detail.data)
      }
    }
  }
</script>

<style>
  .web-container {
    width: 100%;
    height: 100%;
  }
</style>